/*
 * Created on Oct 22, 2003
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.vectrics.user;

import org.vectrics.common.db.JdbcTarget;
import org.vectrics.common.db.ProcessException;
import java.sql.ResultSet;
import java.util.HashSet;
import java.util.Set;
import org.apache.log4j.Logger;



public class FindUserPrivilegesJdbc implements JdbcTarget {
	private transient static Logger log = Logger.getLogger(FindUserPrivilegesJdbc.class);
	
	private String queryStr = "";
	private HashSet roles = new HashSet();		

	public FindUserPrivilegesJdbc(String userName) {                	
		String whereClause = " where";
		whereClause += " (r.user_name = '" + userName + "')";
        
		queryStr = "select r.role_name"
				+ " from user_priv r" 
				+ whereClause;
	}
	

	public Set getRoles() {
		return(roles);
	}
	
	
	public void processResults(ResultSet results) throws ProcessException {
		try {
			while (results.next()) {
				String role = results.getString("role_name");
				roles.add(role);
			}
		}
		catch (java.sql.SQLException se) {
			log.error("processResults() - SQL Exception while processing results list", se);
		}
	}

	
	public String getQuery() {
		return(queryStr);		
	}
}

